package cc.linker.steplink.crm.merchanth5.controller;

import cc.linker.steplink.crm.commons.Constants;
import cc.linker.steplink.crm.commons.domain.WxUser;
import cc.linker.steplink.crm.merchanth5.commons.RequestFilter;
import cc.linker.steplink.crm.merchanth5.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 我的课程
 */
@RequestMapping("/h5/course")
@RestController
public class CourseController {

    @Autowired
    private CourseService courseService;

    @Autowired
    private RequestFilter requestFilter;


    /**
     * 专栏列表
     * @param request
     * @return
     */
    @GetMapping("/mycolums")
    public List<Map<String,Object>> myColumns(
            HttpServletRequest request
    )
    {
        WxUser wxUser =  requestFilter.getWxUser(request);
        String customerId = wxUser.getCustomerId();

        Map<String,Object> params = new HashMap<>();
        params.put("customerId",customerId);
        return courseService.myColumns(params);
    }

    /**
     * 内容列表
     * @param request
     * @return
     */
    @GetMapping("/mycontent")
    public List<Map<String,Object>> myContent(
            HttpServletRequest request
    )
    {
        WxUser wxUser =  requestFilter.getWxUser(request);
        String customerId = wxUser.getCustomerId();

        Map<String,Object> params = new HashMap<>();
        params.put("customerId",customerId);
        return courseService.myContent(params);
    }
}
